<template>
  <van-row>
    <van-nav-bar left-text="返回" title="问题整改详情" @click-left="$emit('onCancel')"/>
    <panel-rectify-base-info :rectify="rectify"/>
    <panel-rectify-extend-info :rectify="rectify"/>
    <panel-rectify-init v-if="step === $vo.RectStep.FIND && rectify.rectify_status === $vo.RectStatus.INIT" :assessType="assessType" :rectify="rectify" @onConfirm="$emit('onConfirm')"/>
    <panel-rectify-plan v-if="step === $vo.RectStep.PLAN && rectify.rectify_status === $vo.RectStatus.TASK" :assessType="assessType" :rectify="rectify" @onConfirm="$emit('onConfirm')"/>
    <panel-rectify-appr v-if="showApprFlag" :assessType="assessType" :rectify="rectify" @onConfirm="$emit('onConfirm')"/>
    <panel-rectify-exec v-if="step === $vo.RectStep.EXEC && rectify.rectify_status === $vo.RectStatus.APPR" :assessType="assessType" :rectify="rectify" @onConfirm="$emit('onConfirm')"/>
    <panel-rectify-acce v-if="showAcceFlag" :assessType="assessType" :rectify="rectify" @onConfirm="$emit('onConfirm')"/>
    <panel-history-process :rectify="rectify"/>
  </van-row>
</template>


<script>
import PanelRectifyBaseInfo from '@/views/rectify/common/panel/PanelRectifyBaseInfo'
import PanelRectifyExtendInfo from '@/views/rectify/common/panel/PanelRectifyExtendInfo'
import PanelHistoryProcess from '@/views/rectify/common/panel/PanelHistoryProcess'
import PanelRectifyInit from '@/views/rectify/common/panel/PanelRectifyInit'
import PanelRectifyPlan from '@/views/rectify/common/panel/PanelRectifyPlan'
import PanelRectifyAppr from '@/views/rectify/common/panel/PanelRectifyAppr'
import PanelRectifyExec from '@/views/rectify/common/panel/PanelRectifyExec'
import PanelRectifyAcce from '@/views/rectify/common/panel/PanelRectifyAcce'
export default {
  name: 'PageRectifyDetail',
  components: { PanelRectifyBaseInfo, PanelRectifyExtendInfo, PanelHistoryProcess, PanelRectifyInit, PanelRectifyPlan, PanelRectifyAppr, PanelRectifyExec, PanelRectifyAcce },
  props: ['assessType', 'step', 'rectify'],
  data(){
    return{
      review_dept:''
    }
  },
  mounted(){
  this.review_dept = this.$route.query.bmmc != undefined ? this.$route.query.bmmc : this.review_dept

  },
  computed: {
    showApprFlag: function () {
      let flag = false
      if (this.assessType === this.$vo.AssessType.DEPT + '') {
        if (this.rectify.flow_type === 1 && this.rectify.rectify_status === this.$vo.RectStatus.PLAN && this.review_dept.indexOf(this.rectify.manage_dept) >= 0) {
          flag = true
        }
        if (this.rectify.rectify_status === this.$vo.RectStatus.PRE_APPR && this.review_dept.indexOf(this.rectify.review_dept) >= 0) {
          flag = true
        }
        if (this.rectify.flow_type === 0 && this.rectify.rectify_status === this.$vo.RectStatus.PLAN && this.review_dept.indexOf(this.rectify.review_dept) >= 0) {
          flag = true
        }
        if (this.step === this.$vo.RectStep.APPR && flag) {
          flag = true
        }
      } else {
        if (this.step === this.$vo.RectStep.APPR && this.rectify.rectify_status === this.$vo.RectStatus.PLAN) {
          flag = true
        }
      }
      return flag
    },
    showAcceFlag: function () {
   
      let flag = false
      if (this.assessType === this.$vo.AssessType.DEPT + '') {
        if (this.rectify.flow_type === 1 && this.rectify.rectify_status === this.$vo.RectStatus.EXEC && this.review_dept.indexOf(this.rectify.manage_dept) >= 0) {
          flag = true
        }
        if (this.rectify.rectify_status === this.$vo.RectStatus.PRE_ACCE && this.review_dept.indexOf(this.rectify.review_dept) >= 0) {
          flag = true
        }
        if (this.rectify.flow_type === 0 && this.rectify.rectify_status === this.$vo.RectStatus.EXEC && this.review_dept.indexOf(this.rectify.review_dept) >= 0) {
          flag = true
        }
        if (this.step === this.$vo.RectStep.ACCE && flag) {
          flag = true
        }
      } else {
        if (this.step === this.$vo.RectStep.ACCE && this.rectify.rectify_status === this.$vo.RectStatus.EXEC) {
          flag = true
        }
      }
      return flag
    }
  }
}
</script>

<style scoped>

</style>
